namespace QMVnSoft.ReportForms
{
    using QMVnSoft;
    using QMVnSoft.Controls;
    using QMVnSoft.DAL;
    using System;
    using System.ComponentModel;
    using System.Drawing;
    using System.Windows.Forms;

    public class FormKCT03TGViewer : FormReportViewer
    {
        private IContainer components;
        private LabelControl lblNgay_Ct1;
        private LabelControl lblNgay_Ct2;
        private LabelControl lblTk;
        private TextDate txtNgay_Ct1;
        private TextDate txtNgay_Ct2;
        private TextControl txtTen_Tk;
        private TextSearch txtTk;

        public FormKCT03TGViewer()
        {
            this.InitializeComponent();
            this.txtNgay_Ct1.Value = AppInstance.StartWorkingDate;
            this.txtNgay_Ct2.Value = AppInstance.EndWorkingDate;
            this.txtTk.Value = "112";
            this.txtTen_Tk.Value = this.txtTk.GetFieldData("Ten_Tk");
        }

        public FormKCT03TGViewer(object pd_Ngay_Ct1, object pd_Ngay_Ct2, object ps_Tk, object pi_Loai_Tte)
        {
            this.InitializeComponent();
            this.txtNgay_Ct1.Value = pd_Ngay_Ct1;
            this.txtNgay_Ct2.Value = pd_Ngay_Ct2;
            this.txtTk.Value = ps_Tk;
            this.txtTen_Tk.Value = this.txtTk.GetFieldData("Ten_Tk");
            this.OnMakeReport();
        }

        protected override void Dispose(bool disposing)
        {
            if (disposing && (this.components != null))
            {
                this.components.Dispose();
            }
            base.Dispose(disposing);
        }

        private void InitializeComponent()
        {
            //ComponentResourceManager manager = new ComponentResourceManager(typeof(FormKCT03TGViewer));
            this.txtTen_Tk = new TextControl();
            this.txtTk = new TextSearch();
            this.lblTk = new LabelControl();
            this.txtNgay_Ct2 = new TextDate();
            this.lblNgay_Ct2 = new LabelControl();
            this.txtNgay_Ct1 = new TextDate();
            this.lblNgay_Ct1 = new LabelControl();
            base.rptContainer.Panel1.SuspendLayout();
            base.rptContainer.SuspendLayout();
            base.SuspendLayout();
            base.rptContainer.Panel1.Controls.Add(this.txtNgay_Ct2);
            base.rptContainer.Panel1.Controls.Add(this.lblNgay_Ct2);
            base.rptContainer.Panel1.Controls.Add(this.txtNgay_Ct1);
            base.rptContainer.Panel1.Controls.Add(this.lblNgay_Ct1);
            base.rptContainer.Panel1.Controls.Add(this.txtTen_Tk);
            base.rptContainer.Panel1.Controls.Add(this.txtTk);
            base.rptContainer.Panel1.Controls.Add(this.lblTk);
            base.rptContainer.Panel1.Paint += new PaintEventHandler(this.rptContainer_Panel1_Paint);
            base.rptContainer.SplitterDistance = 0x2e;
            this.txtTen_Tk.Anchor = AnchorStyles.Right | AnchorStyles.Left | AnchorStyles.Top;
            this.txtTen_Tk.BackColor = SystemColors.Control;
            this.txtTen_Tk.BorderStyle = BorderStyle.None;
            this.txtTen_Tk.CheckTextSearched = false;
            this.txtTen_Tk.DisabledForeColor = Color.Blue;
            this.txtTen_Tk.Enabled = false;
            this.txtTen_Tk.Font = new Font("Arial", 8.25f);
            this.txtTen_Tk.ForeColor = Color.Blue;
            this.txtTen_Tk.Location = new Point(0xd6, 6);
            this.txtTen_Tk.Name = "txtTen_Tk";
            this.txtTen_Tk.OldValue = null;
            this.txtTen_Tk.Size = new Size(0x1ca, 13);
            this.txtTen_Tk.TabIndex = 0x5b;
//            this.txtTen_Tk.Value = null;//manager.GetObject("txtTen_Tk.Value");
            this.txtTk.CharacterCasing = CharacterCasing.Upper;
            this.txtTk.CheckTextSearched = false;
            this.txtTk.DisabledForeColor = Color.Empty;
            this.txtTk.FieldDisplay = "Ten_Tk";
            this.txtTk.Font = new Font("Arial", 8.25f);
            this.txtTk.FoundIsValid = true;
            this.txtTk.Location = new Point(0x6c, 3);
            this.txtTk.MaxLength = 0x20;
            this.txtTk.Name = "txtTk";
            this.txtTk.OldValue = null;
            this.txtTk.Size = new Size(100, 20);
            this.txtTk.TabIndex = 0;
            this.txtTk.TableName = "DMTK";
            this.txtTk.TextDisplay = this.txtTen_Tk;
            this.txtTk.UserTextLength = AppInstance.TextControlLength.ItemCode;
            this.txtTk.UserTrimMode = AppInstance.TextControlTrimMode.All;
//            this.txtTk.Value = null;//manager.GetObject("txtTk.Value");
            this.lblTk.AutoSize = true;
            this.lblTk.Font = new Font("Arial", 8.25f);
            this.lblTk.Location = new Point(12, 6);
            this.lblTk.Name = "lblTk";
            this.lblTk.Size = new Size(0x35, 14);
            this.lblTk.TabIndex = 0x57;
            this.lblTk.Text = "Tài khoản";
            this.txtNgay_Ct2.DateTimeFormat = TextDate.DateTimeFormatType.Date;
            this.txtNgay_Ct2.Font = new Font("Arial", 8.25f);
            this.txtNgay_Ct2.InsertKeyMode = InsertKeyMode.Overwrite;
            this.txtNgay_Ct2.Location = new Point(0x13c, 0x18);
            this.txtNgay_Ct2.Mask = "00/00/0000";
            this.txtNgay_Ct2.Name = "txtNgay_Ct2";
            this.txtNgay_Ct2.OldValue = null;
            this.txtNgay_Ct2.Size = new Size(100, 20);
            this.txtNgay_Ct2.TabIndex = 6;
//            this.txtNgay_Ct2.Value = null;//manager.GetObject("txtNgay_Ct2.Value");
            this.lblNgay_Ct2.AutoSize = true;
            this.lblNgay_Ct2.Font = new Font("Arial", 8.25f);
            this.lblNgay_Ct2.Location = new Point(0x100, 0x1b);
            this.lblNgay_Ct2.Name = "lblNgay_Ct2";
            this.lblNgay_Ct2.Size = new Size(0x36, 14);
            this.lblNgay_Ct2.TabIndex = 0x61;
            this.lblNgay_Ct2.Text = "Đến ngày";
            this.txtNgay_Ct1.DateTimeFormat = TextDate.DateTimeFormatType.Date;
            this.txtNgay_Ct1.Font = new Font("Arial", 8.25f);
            this.txtNgay_Ct1.InsertKeyMode = InsertKeyMode.Overwrite;
            this.txtNgay_Ct1.Location = new Point(0x6c, 0x18);
            this.txtNgay_Ct1.Mask = "00/00/0000";
            this.txtNgay_Ct1.Name = "txtNgay_Ct1";
            this.txtNgay_Ct1.OldValue = null;
            this.txtNgay_Ct1.Size = new Size(100, 20);
            this.txtNgay_Ct1.TabIndex = 5;
//            this.txtNgay_Ct1.Value = null;//manager.GetObject("txtNgay_Ct1.Value");
            this.lblNgay_Ct1.AutoSize = true;
            this.lblNgay_Ct1.Font = new Font("Arial", 8.25f);
            this.lblNgay_Ct1.Location = new Point(12, 0x1b);
            this.lblNgay_Ct1.Name = "lblNgay_Ct1";
            this.lblNgay_Ct1.Size = new Size(0x2f, 14);
            this.lblNgay_Ct1.TabIndex = 0x62;
            this.lblNgay_Ct1.Text = "Từ ngày";
            base.AutoScaleDimensions = new SizeF(6f, 13f);
            base.CheckDetailMost = true;
            base.ClientSize = new Size(0x31a, 0x1cf);
            base.Name = "FormKCT03TGViewer";
            base.rptContainer.Panel1.ResumeLayout(false);
            base.rptContainer.Panel1.PerformLayout();
            base.rptContainer.ResumeLayout(false);
            base.ResumeLayout(false);
            base.PerformLayout();
        }

        protected override void OnGenerateColumns()
        {
            if (base.CurrencyIndex == 0)
            {
                object[][] objArray = new object[8][];
                object[] objArray2 = new object[4];
                objArray2[0] = "Ngay_Ps";
                objArray2[1] = "Ngày ghi sổ";
                objArray2[2] = "D";
                objArray[0] = objArray2;
                object[] objArray3 = new object[4];
                objArray3[0] = "Ngay_Ct";
                objArray3[1] = "Ngày chứng từ";
                objArray3[2] = "D";
                objArray[1] = objArray3;
                object[] objArray4 = new object[4];
                objArray4[0] = "So_Ct";
                objArray4[1] = "Số chứng từ";
                objArray4[2] = "C";
                objArray[2] = objArray4;
                object[] objArray5 = new object[4];
                objArray5[0] = "Dien_Giai";
                objArray5[1] = "Diễn giải";
                objArray5[2] = "C";
                objArray[3] = objArray5;
                object[] objArray6 = new object[4];
                objArray6[0] = "Tk_Du";
                objArray6[1] = "Tk Đ/ứ";
                objArray6[2] = "C";
                objArray[4] = objArray6;
                objArray[5] = new object[] { "Ps_No", "Phát sinh nợ", "N", AppInstance.TextNumericFormat.LocalAmount };
                objArray[6] = new object[] { "Ps_Co", "Phát sinh có", "N", AppInstance.TextNumericFormat.LocalAmount };
                objArray[7] = new object[] { "Du_Cuoi", "Dư cuối", "N", AppInstance.TextNumericFormat.LocalAmount };
                base.LocalColNames = objArray;
            }
            else
            {
                object[][] objArray10 = new object[12][];
                object[] objArray11 = new object[4];
                objArray11[0] = "Ngay_Ps";
                objArray11[1] = "Ngày ghi sổ";
                objArray11[2] = "D";
                objArray10[0] = objArray11;
                object[] objArray12 = new object[4];
                objArray12[0] = "Ngay_Ct";
                objArray12[1] = "Ngày chứng từ";
                objArray12[2] = "D";
                objArray10[1] = objArray12;
                object[] objArray13 = new object[4];
                objArray13[0] = "So_Ct";
                objArray13[1] = "Số chứng từ";
                objArray13[2] = "C";
                objArray10[2] = objArray13;
                object[] objArray14 = new object[4];
                objArray14[0] = "Dien_Giai";
                objArray14[1] = "Diễn giải";
                objArray14[2] = "C";
                objArray10[3] = objArray14;
                object[] objArray15 = new object[4];
                objArray15[0] = "Tk_Du";
                objArray15[1] = "Tk Đ/ứ";
                objArray15[2] = "C";
                objArray10[4] = objArray15;
                objArray10[5] = new object[] { "Ps_No", "Ps Nợ", "N", AppInstance.TextNumericFormat.LocalAmount };
                objArray10[6] = new object[] { "Ps_Co", "Ps C\x00f3", "N", AppInstance.TextNumericFormat.LocalAmount };
                objArray10[7] = new object[] { "Du_Cuoi", "Dư cuối", "N", AppInstance.TextNumericFormat.LocalAmount };
                objArray10[8] = new object[] { "Ty_Gia", "Tỷ giá", "N", AppInstance.TextNumericFormat.LocalAmount };
                objArray10[9] = new object[] { "Ps_No_Nt", "Ps Nợ Nt", "N", AppInstance.TextNumericFormat.LocalAmount };
                objArray10[10] = new object[] { "Ps_Co_Nt", "Ps C\x00f3 Nt", "N", AppInstance.TextNumericFormat.LocalAmount };
                objArray10[11] = new object[] { "Du_Cuoi_Nt", "Dư cuối Nt", "N", AppInstance.TextNumericFormat.LocalAmount };
                base.ForeignColNames = objArray10;
            }
            base.OnGenerateColumns();
        }

        protected override void OnMakeReport()
        {
            AppInstance.StartWorkingDate = (DateTime) this.txtNgay_Ct1.Value;
            AppInstance.EndWorkingDate = (DateTime) this.txtNgay_Ct2.Value;
            this.OnGenerateColumns();
            base.LocalTable = new ReportDataAccess().KCT03_Get(AppInstance.Subsidiaries, this.txtNgay_Ct1.Value, this.txtNgay_Ct2.Value, this.txtTk.Value, AppInstance.DefLanguage);
            base.OnMakeReport();
        }

        protected override void OnSendParameters()
        {
            base.StimulReport["Ngay"] = "Từ ngày " + string.Format("{0:dd/MM/yyyy}", this.txtNgay_Ct1.Value) + " đến ngày " + string.Format("{0:dd/MM/yyyy}", this.txtNgay_Ct2.Value);
            if (string.IsNullOrEmpty(this.txtTk.Value.ToString()))
            {
                base.StimulReport["TaiKhoan"] = "";
            }
            else
            {
                base.StimulReport["TaiKhoan"] = string.Concat(new object[] { "Tài khoản: ", this.txtTen_Tk.Value, " (", this.txtTk.Value, ")" });
            }
        }

        private void rptContainer_Panel1_Paint(object sender, PaintEventArgs e)
        {
        }
    }
}

